package com.xh.service.impl;

import com.xh.model.dto.Tuple2;
import com.xh.model.request.PreviewRequest;
import com.xh.poster.core.abst.Poster;
import com.xh.poster.core.impl.PosterDefaultImpl;
import com.xh.service.CorePostersService;
import com.xh.service.PostersService;
import com.xh.utils.FileUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.awt.image.BufferedImage;
import java.io.InputStream;

/**
 * <p>
 * 海报生成核心 服务实现类
 * </p>
 *
 * @author wen
 * @since 2021-07-08
 */
@Service
public class CorePostersServiceImpl implements CorePostersService {

    @Override
    public InputStream createPoster(PreviewRequest request) {
        PosterDefaultImpl<Object> posterDefault = new PosterDefaultImpl<>();
        BufferedImage image = posterDefault.paramsDrawPoster(request).draw(null);
        return FileUtil.bufferedImageToInputStream(image, request.getType());
    }

}
